package com.gjzt.business.media.controller;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eastdigit.servlet.RequestAttribute;
import com.eastdigit.servlet.Response;
import com.eastdigit.servlet.ReqBean;
import com.gjzt.business.media.service.BusTypeService;

@Controller
@RequestMapping(value = "/busType")
public class BusTypeController {

    @Autowired
    private BusTypeService busTypeService;

    /**
     * 查询
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/query")
    @ResponseBody
    public JSONObject queryBusType(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        return Response.response(busTypeService.findBusType(reqBean));
    }

    /**
     * 添加
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public JSONObject addBusType(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        busTypeService.addBusType(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 修改
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public JSONObject updateBusType(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
        busTypeService.updateBusType(reqBean);
        return Response.responseSuccess();
    }

    /**
     * 失效
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/{typeId}/disable")
    @ResponseBody
    public JSONObject disableBusType(@PathVariable String typeId) {
        busTypeService.disableBusType(typeId);
        return Response.responseSuccess();
    }
    
    /**
     * 生效
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/{typeId}/revert")
    @ResponseBody
    public JSONObject revertBusType(@PathVariable String typeId) {
        busTypeService.revertBusType(typeId);
        return Response.responseSuccess();
    }

    //TODO 其他功能
}